Writing Tests
- Copy the sample repository structure
- Remove
student_solution
. execute.sh
,Driver.java
should not be changed under any circumstances.test_cases/
,info_file.txt
should have the same format as followed in the files in the sample link.- Test only one class in each test case.
- While writing a test case i.e. in a class called
Test
intest_cases/Test<test_no>.java
in functionpublic int test()
, check only for the correctness of a value and return the marks. All other cases will be handled by the framework. - Add a new line corresponding to the test in
info_file.txt
. The first parameter is the test file, followed by the class to be tested and the timelimit in seconds. - The pushed code should have only
author_solution/
,test_cases/
,Driver.java
,execute.sh
,info_file.txt
as in the sample link.
Procedure
- Push the testing code to GitLab in repository
lab_author/<lab_name>
- Push the skeleton code and lab question PDF to GitLab in repository
lab_author/lab_source/
in directory<lab_name>
- After pushing the code, open the
labs.json
file in the main server. -
Add a new JSON entry in the Labs array which should be identical to this:
{ "Lab_No": "1", "start_date": "2", "start_month": "4", "start_year": "2016", "start_hour": "3", "start_minute": "00", "end_date": "12", "end_month": "4", "end_year": "2016", "end_hour": "22", "end_minute": "00", "hard_date": "12", "hard_month": "4", "hard_year": "2016", "hard_hour": "23", "hard_minute": "10", "penalty": "10" }
-
Restart the web server.
Example
- Download skeleton directory for a lab testing framework from code base
- Login to GitLab with user account
lab_author
- Create a repo as
<lab_name>
. For examplelab1
. - Clone this repo to your local machine.
- Move the downloaded code to this repo directory.
- Remove the
student_solution/
directory. - Put the lab solution in
author_solution
. execute.sh
,Driver.java
should not be changed under any circumstances.test_cases/
,info_file.txt
should have the same format as followed in the files in the sample link.- Test only one class in each test case.
- For each test case, create a class called
Test
intest_cases/Test<test_no>.java
in functionpublic int test()
. For example -Test1.java
should have a class calledTest
.Test
will have a functionpublic int test()
. - Check only for the correctness of a value and return the marks. All other cases will be handled by the framework. For example - if a test case is worth 2 marks, make relevant class objects and check for the correct answers using if statements. In all correct scenario, return 2 otherwise return 0. Check Test1.java in the sample repo. Don't worry about compilation errors, runtime errors/exceptions or infinite loops. These will be handled automatically.
- Add a new line corresponding to the test in
info_file.txt
. The first parameter is the test file, followed by the class to be tested and the timelimit in seconds. For example, if the class you are testing isSeller.java
in test case 1 then the corresponding entry will look like this for a1 second
time limit. -Test1.java Seller.java 1
. Seeinfo_file.txt
in the sample repo for more clarity. - Repeat above three points for as many test cases as you want.
- By now you will have the following files
author_solution/
,test_cases/
,Driver.java
,execute.sh
,info_file.txt
as in the sample link. - Push this code to GitLab. Your testing repo is ready.
- Put any skeleton code and lab question PDF in a repo
lab_source
with<lab_name>
as the subdirectory. For example,lab_source/lab1
. - After performing the two pushes, open the
labs.json
file in the main server. -
Add a new JSON entry in the Labs array which should be identical to this:
{ "Lab_No": "lab1", "start_date": "2", "start_month": "4", "start_year": "2016", "start_hour": "3", "start_minute": "00", "end_date": "12", "end_month": "4", "end_year": "2016", "end_hour": "22", "end_minute": "00", "hard_date": "12", "hard_month": "4", "hard_year": "2016", "hard_hour": "23", "hard_minute": "10", "penalty": "10" }
-
Restart the web server.